package com.dragon.modules.yuegou.enums.code;

import com.dragon.common.constant.enums.IBusinessCode;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 物业水电费错误代码
 * 
 * @author pengxin
 *
 */
public enum FeeCode implements IBusinessCode {

	INSTRUMENT_NOT_EXIST(21001, "%s仪表信息不正确"),

	ROOM_NOT_EXIST(21002, "%s房间信息不正确"),

	USER_DOORNO_EXISTED(21003, "用户和户号对应已存在"),

	UNAYU_SYSTEM_BUSY(21004, "系统繁忙，请稍后再试"),

	SYNCHRONIZATION_INFORMATION_ERROR(21005, "同步智能设备出现错误"),

	DOOR_NO_NOT_FOUND(21006, "该仪表没有绑定户号无法清零"),

	FLOOR_NOT_EXIST(21007, "%s楼层信息不正确"),

	BUILDING_NOT_EXIST(21008, "%s楼栋信息不正确"),

	ROOM_IS_EXIST(21010, "%s此房间名已存在"),

	INSTRUMENT_BIND_ALREADY(21011, "此房间已经绑定了该类型的仪表！"),

	INTELLIGENT_CAN_NOT_OFFLINE_PAY(21012, "该设备为智能仪表不能进行线下缴费！"),

	NOT_BIND_INSTRUMENT(21013, "该房间还没有绑定此类型的仪表！"),

	BALANCE_CANNOT_BE_NEGATIVE(21014, "余额为负数时无法退组！"),

	INSTRUMENT_BIND_DOORNO_ALREADY(21015, "此仪表已经绑定了户号,无法重复绑定！"),

	INSTRUMENT_NOT_BIND_DOORNO(21017, "当前仪表没有绑定户号无法添加抄表记录！"),

	MOBILE_LENGTH_INCORRECT(21018, "请输入正确的手机号码！"),

	ROOM_ID_IS_NO_NULL(21019, "请选择房间！"),

	INSTRUMENT_TYPE_IS_INCORRECT(21020, "%s仪表属性不正确，请输入正确的仪表属性(电表或水表)"),

	ROOM_TYPE_IS_INCORRECT(21021, "%s房间属性不正确，请输入正确的房间属性(商业或住宅)"),

	IMPORT_ROOM_NAME_IS_NOT_NULL(21022, "%s房间名称不能为空"),

	IMPORT_BUILDING_NAME_IS_NOT_NULL(21023, "%s所属楼栋不能为空"),

	IMPORT_FLOOR_NAME_IS_NOT_NULL(21024, "%s所处楼层不能为空"),

	IMPORT_ATTRIBUTE_NAME_IS_NOT_NULL(21025, "%s房间属性不能为空"),

	DOORNO_IS_NULL(21026, "户号不存在"),

	NEW_DOORNO_IS_NULL(21027, "请联系管理员"),

	MONEY_DISSATISFY_REQUESTED(21028, "金额不能低于%s元"),

	CUSTOMER_NAME_IS_NOT_BULL(21029, "客户名称不能为空"),

	CONTACTS_NAME_IS_NOT_NULL(21030, "联系人不能为空"),

	CONTACTS_MOBILE_IS_NOT_NULL(21031, "联系电话不能为空"),

	FLOOR_ID_IS_NO_NULL(21032, "请选择楼层"),

	BUILDING_ID_IS_NO_NULL(21033, "请选择楼栋"),

	IMPORT_DOOR_NO_IS_ALREADY_BIND(21034, "%s户号已被绑定,无法继续绑定"),

	DOOR_NO_IS_ALREADY_BIND(21035, "%s此房间的户号已被绑定,无法继续绑定"),

	FLOOR_NO_WRONG_FORMAT(21036, "%s楼层编号只能有数字或英文组成，且最大长度为2位"),

	ROOM_NO_WRONG_FORMAT(21037, "%s房间户号只能有数字或英文组成，且最大长度为4位"),

	IMPORT_ELECTRIC_IS_ALREADY_BIND(21038, "%s电表已经绑定其他户号！"),

	IMPORT_WATER_IS_ALREADY_BIND(21039, "%s水表已经绑定其他户号！"),

	PHYSICALNO_ERROR(21040, "物理编号与户号无法对应"),
	
	TEMPLATE_ERROR(21041, "导入模板不正确！请检查模板！"),
	
	TEMPLATE_DATA_IS_EMPTY(21043, "导入表格数据为空！"),



	/**
	 * 状态码说明
	 */
	TODO(21000, "提示消息");
	private final Integer code;

	private final String message;

	private FeeCode(Integer code, String message) {
		this.code = code;
		this.message = message;
	}

	public Integer getCode() {
		return code;
	}

	public String getMessage() {
		return message;
	}

	/**
	 * 把code转化为ResponseCode枚举
	 * 
	 * @param code
	 *            代码
	 * @return
	 */
	public static FeeCode from(Integer code) {
		if (code == null) {
			return null;
		}
		return CODE_MAP.get(code);
	}

	/**
	 * Code Map for ResponseCode
	 */
	private static final Map<Integer, FeeCode> CODE_MAP = Stream.of(FeeCode.values())
			.collect(Collectors.toMap(FeeCode::getCode, e -> e));

}
